﻿using System.Web.Mvc;

namespace CodeContrib.Web.Mvc
{
	public class PermanentRedirectResult : HttpStatusCodeResult
	{
		private readonly string _redirectUrl;

		public PermanentRedirectResult(string redirectUrl) : base(301)
		{
			Guard.NotNullOrEmpty(redirectUrl, "redirectUrl");

			_redirectUrl = redirectUrl;
		}

		public override void ExecuteResult(ControllerContext context)
		{
			context.HttpContext.Response.RedirectLocation = _redirectUrl;
		}
	}
}